<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
  <th:block th:include="include :: header('数据可见')" />
  <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
  <form class="form-horizontal m" id="form-projectInfoVisible-add">
    <input id="projectId" name="projectId" th:value="${projectId}"  type="hidden">
    <div class="form-group">
      <label class="col-sm-3 control-label"><span style="color: red; ">*</span>可见人员：</label>
      <div class="col-sm-8">
        <select id="partner" class="form-control select2-multiple" multiple required>
          <option th:each="user:${users}" th:value="${user.userId}" th:text="${user.userName}" th:selected="${user.flag}"></option>
        </select>
      </div>
    </div>
  </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script type="text/javascript">
  var prefix = ctx + "project/projectInfo";
  $("#form-projectInfoVisible-add").validate({
    ignore: "",
    errorPlacement: function(error, element) {
      if (element.is("select")){
        error.appendTo(element.parent());
      } else {
        error.insertAfter(element);
      }
    }
  });

  function submitHandler() {
    if ($.validate.form()) {
      let data = $("#form-projectInfoVisible-add").serializeArray();
      let userIds = $.form.selectSelects("partner");
      data.push({"name": "visibleUserId", "value": userIds});
      $.operate.save(prefix + "/editVisible", data);
    }
  }
</script>
</body>
</html>